<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text"  id="timestamp"/>
<script type="text/javascript">
    (function () {
        var timeStamp=document.getElementById("timestamp");
        alert(timeStamp.firstChild == null)
        if(timeStamp.firstChild == null){
            timeStamp.appendChild(document.createTextNode(new Date().toString()));
            timeStamp.style.backgroundColor="yellow";
            timeStamp.className="highlight";
            timeStamp.onclick=function () {
                this.innerHTML=new Date().toString();
            }
        };
        function textContent(e){
            var child,type,s="";
            for(child =e.firstChild;child!=null;child=child.nextSibling){
                type=child.nodeType;
                if(type ===3 || type ===4)
                        s+=child.nodeValue;
                else if(type ===1)
                        s+=textContent(child);
            };
            return s;
        };
        console.log(textContent(document.getElementById("timestamp")));
    })();
</script>
</body>
</html>